import React, { useContext } from 'react';
import { ColorContext, UPDATE_COLOR } from "./Color";

function Buttons() {
    const { dispatch } = useContext(ColorContext);
    return (
        <div>
            <button onClick={() => dispatch({ type: UPDATE_COLOR, color: 'blue' })}>蓝色</button>
            <button onClick={() => dispatch({ type: UPDATE_COLOR, color: 'red' })} style={{ marginLeft: `10px` }}>红色</button>
        </div>
    )
}

export default Buttons